﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Nodes;
using System.Threading.Tasks;

namespace IM.Easy.SystemServices.Dtos
{
    /// <summary>
    /// Vue 路由信息
    /// </summary>
    public class VueRoute
    {
        /// <summary>
        /// id主键
        /// </summary>
        public long Id { get; set; }

        /// <summary>
        /// 路由的路径
        /// </summary>
        public string Path { get; set; }

        /// <summary>
        /// 路由的名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 路由对应的组件
        /// </summary>
        public string Component { get; set; }

        /// <summary>
        /// 可见性
        /// </summary>
        public bool Hidden { get; set; }

        //public bool AlwaysShow { get; set; }

        public bool AlwaysShow
        {
            get
            {
                var show = Children != null && Children.Any(s => !s.Hidden);
                show = show && !IsVirtual;
                return show;
            }
        }

        /// <summary>
        /// 子路由
        /// </summary>
        public List<VueRoute> Children { get; set; }

        /// <summary>
        /// 是否需要身份验证
        /// </summary>
        public bool RequiresAuth { get; set; }

        ///// <summary>
        ///// 路由的元数据
        ///// </summary>
        //public Dictionary<string, object> Meta { get; set; }
        public JsonObject Meta { get; set; }

        /// <summary>
        /// 重定向路径
        /// </summary>
        public string Redirect { get; set; }

        /// <summary>
        /// 是否虚拟菜单  虚拟菜单不做显示
        /// </summary>
        public bool IsVirtual { get; set; }

        public VueRoute()
        {
            Children = [];
            //Meta = new Dictionary<string, object>();
            Meta = [];
        }
    }

}
